<?php

namespace app\model;

use think\Model;

class RegisterField extends Model
{
    protected $connection = 'mysql';

    protected $pk = 'id';

    protected $name = 'register_field';

    public static function getField($ptype)
    {
        return self::where(['weid' => weid(), 'ptype' => $ptype, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
    }
    public static function getsysField($ptype)
    {
        return self::where(['weid' => weid(), 'ptype' => $ptype, 'is_sys' => 1, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
    }
    public static function getsnoysField($ptype)
    {
        return self::where(['weid' => weid(), 'ptype' => $ptype, 'is_sys' => 0, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
    }
    public static function getfrontField($ptype, $update = '')
    {
        $query = self::where(['weid' => weid(), 'ptype' => $ptype, 'is_front' => 1, 'status' => 1]);
        if (!empty($update)) {
            $query->where('fieldsmingcheng', '<>', 'username');
            $query->where('fieldsmingcheng', '<>', 'password');
        }
        return $query->order('sort asc,id asc')->select()->toArray();
    }
    public static function getimportField($ptype)
    {
        return self::where(['weid' => weid(), 'ptype' => $ptype, 'is_import' => 1, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
    }
    public static function getlistViewField($ptype)
    {
        return self::where(['weid' => weid(), 'is_listView' => 1, 'ptype' => $ptype, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
    }
    public static function getinputField($ptype)
    {
        return self::where(['weid' => weid(), 'is_input' => 1, 'ptype' => $ptype, 'status' => 1])->order('sort asc,id asc')->select()->toArray();
    }

    public static function fieldToData($registerfield)
    {
        if (!empty($registerfield)) {
            foreach ($registerfield as $vo) {
                if ($vo['inputtype'] == 'date') {
                    $vo['fieldsvalue'] = strtotime($vo['fieldsvalue']);
                }
                if ($vo['inputtype'] == 'checkbox') {
                    $vo['fieldsvalue'] = implode(',', $vo['fieldsvalue']);
                }
                if ($vo['inputtype'] == 'tag') {
                    $vo['fieldsvalue'] = implode(',', $vo['selectvaluearray']);
                }
                if ($vo['inputtype'] == 'picss') {
                    $vo['fieldsvalue'] = json_encode($vo['fieldsvalue']);
                }
                if ($vo['inputtype'] == 'lbs') {
                    if ($vo['is_sys'] == 1) {
                        $fieldsvalue = $vo['fieldsvalue'];
                        // $data['province_ids'] = $fieldsvalue;
                        $data['province_name'] = $fieldsvalue['province_name'];
                        $data['city_name'] = $fieldsvalue['city_name'];
                        $data['district_name'] = $fieldsvalue['district_name'];
                        $data['dizhi'] = $fieldsvalue;
                        $data['house_number'] = $fieldsvalue['house_number'];
                        // $data['latitude'] = $fieldsvalue['latitude'];
                        // $data['longitude'] = $fieldsvalue['longitude'];
                        if (!empty($data['province_name']) && !empty($data['city_name']) && !empty($data['district_name'])) {
                            $area_id = Area::get_area_id([$data['province_name'], $data['city_name'], $data['district_name']]);
                            $data['province'] = $area_id[0];
                            $data['city'] = $area_id[1];
                            $data['district'] = $area_id[2];
                        }
                        $vo['fieldsvalue'] = $fieldsvalue['region_name'];
                    } else {
                        $vo['fieldsvalue'] = serialize($vo['fieldsvalue']);
                    }
                }
                if ($vo['is_sys'] == 1) {
                    $data[$vo['fieldsmingcheng']] = $vo['fieldsvalue'];
                } else {
                    $customtext[$vo['inputtype']][$vo['id']] = $vo['fieldsvalue'];
                }
                // if ($vo['fieldsmingcheng'] == 'address') {
                //     $res=Geocoder::geocoding($vo['fieldsvalue']);
                //     $data['latitude']= number_format($res['latitude'], 6);
                //     $data['longitude']= number_format($res['longitude'], 6);
                // }
            }
            if (!empty($data['province_ids'])) {
                $area = $data['province_ids'];
                $data['province_id'] = $area[0];
                $data['city_id'] = $area[1];
                $data['district_id'] = $area[2];

                $data['province'] = $area[0];
                $data['city'] = $area[1];
                $data['district'] = $area[2];

                $data['province_name'] = Area::get_area_name($data['province_id']);
                $data['city_name'] = Area::get_area_name($data['city_id']);
                $data['district_name'] = Area::get_area_name($data['district_id']);
            }
            if (!empty($data['region'])) {
                $area = $data['region'];
                $data['province_id'] = $area[0];
                $data['city_id'] = $area[1];
                $data['district_id'] = $area[2];

                $data['province'] = $area[0];
                $data['city'] = $area[1];
                $data['district'] = $area[2];

                $data['province_name'] = Area::get_area_name($data['province_id']);
                $data['city_name'] = Area::get_area_name($data['city_id']);
                $data['district_name'] = Area::get_area_name($data['district_id']);
            }
            unset($data['province_ids']);
            $data['customtext'] = serialize($customtext);
            $data["update_time"] = time();
        }

        return  $data;
    }

    public static function datainitial($ptype)
    {
        $weid = weid();
        $data['member'] = [
            [
                'fieldsmingcheng' => 'userpic',
                'viewmingcheng' => '头像',
                'inputtype' => 'pics',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'nickname',
                'viewmingcheng' => '昵称',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'password',
                'viewmingcheng' => '密码',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 0,
            ],
            [
                'fieldsmingcheng' => 'gid',
                'viewmingcheng' => '会员等级',
                'inputtype' => 'select',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'pid',
                'viewmingcheng' => '推荐人',
                'inputtype' => 'text',
                'is_front' => 0,
                'is_input' => 0,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'telephone',
                'viewmingcheng' => '手机号',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'address',
                'viewmingcheng' => '地址',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1
            ],
            [
                'fieldsmingcheng' => 'balance',
                'viewmingcheng' => '余额',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'points',
                'viewmingcheng' => '积分',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'regdate',
                'viewmingcheng' => '注册时间',
                'inputtype' => 'text',
                'is_input' => 0,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'lastdate',
                'viewmingcheng' => '最后登录',
                'inputtype' => 'text',
                'is_input' => 0,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'email',
                'viewmingcheng' => '邮箱',
                'inputtype' => 'text',
                'is_import' => 1,
                'is_input' => 1
            ],
            [
                'fieldsmingcheng' => 'status',
                'viewmingcheng' => '是否审核',
                'is_import' => 1,
                'inputtype' => 'switch',
                'is_input' => 1
            ]

        ];

        $data['agent'] = [
            [
                'fieldsmingcheng' => 'title',
                'viewmingcheng' => '姓名',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'tel',
                'viewmingcheng' => '手机号',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'touxiang',
                'viewmingcheng' => '头像',
                'inputtype' => 'pics',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'pid_code',
                'viewmingcheng' => '邀请码',
                'inputtype' => 'text',
                'is_sys' => 0,
                'is_front' => 0,
                'is_input' => 0,
                'is_import' => 0,
                'is_listView' => 0
            ],
            [
                'fieldsmingcheng' => 'total_income',
                'viewmingcheng' => '总收入',
                'inputtype' => 'text',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'income',
                'viewmingcheng' => '收入',
                'inputtype' => 'text',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'cash',
                'viewmingcheng' => '已提现',
                'inputtype' => 'text',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'no_cash',
                'viewmingcheng' => '未提现',
                'inputtype' => 'text',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'create_time',
                'viewmingcheng' => '加入时间',
                'inputtype' => 'text',
                'is_front' => 0,
                'is_input' => 0,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'email',
                'viewmingcheng' => '邮箱',
                'inputtype' => 'text',
                'is_front' => 0,
                'is_import' => 1,
                'is_input' => 1
            ],
            [
                'fieldsmingcheng' => 'status',
                'viewmingcheng' => '是否审核',
                'inputtype' => 'switch',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1
            ]

        ];

        $data['complete'] = [
            [
                'fieldsmingcheng' => 'process',
                'viewmingcheng' => '施工过程',
                'inputtype' => 'pics',
                'is_sys' => 0,
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 0,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'acceptance',
                'viewmingcheng' => '验收现场',
                'inputtype' => 'pics',
                'is_sys' => 0,
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 0,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'customeracceptance',
                'viewmingcheng' => '顾客验收表',
                'inputtype' => 'pics',
                'is_sys' => 0,
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 0,
                'is_listView' => 1
            ]

        ];

        $data['technical'] = [
            [
                'fieldsmingcheng' => 'username',
                'viewmingcheng' => '帐号',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'password',
                'viewmingcheng' => '密码',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 0,
            ],
            [
                'fieldsmingcheng' => 'title',
                'viewmingcheng' => '姓名',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'level',
                'viewmingcheng' => '等级',
                'inputtype' => 'select',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'category_id',
                'viewmingcheng' => '分类',
                'inputtype' => 'select',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 0
            ],
            [
                'fieldsmingcheng' => 'tel',
                'viewmingcheng' => '手机号',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'touxiang',
                'viewmingcheng' => '头像',
                'inputtype' => 'pics',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'idpic1',
                'viewmingcheng' => '身份证正面',
                'inputtype' => 'pics',
                'is_sys' => 0,
                'is_front' => 1,
                'is_import' => 1,
                'is_input' => 1
            ],
            [
                'fieldsmingcheng' => 'idpic2',
                'viewmingcheng' => '身份证背面',
                'inputtype' => 'pics',
                'is_sys' => 0,
                'is_front' => 1,
                'is_import' => 1,
                'is_input' => 1
            ],
            [
                'fieldsmingcheng' => 'workunits',
                'viewmingcheng' => '工作单位',
                'inputtype' => 'text',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 0
            ],
            [
                'fieldsmingcheng' => 'region_name',
                'viewmingcheng' => '位置',
                'inputtype' => 'lbs',
                'is_sys' => 1,
                'is_front' => 1,
                'is_import' => 1,
                'is_input' => 0
            ],
            [
                'fieldsmingcheng' => 'province_id',
                'viewmingcheng' => '地区',
                'inputtype' => 'select',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'cate_ids',
                'viewmingcheng' => '可接的服务',
                'inputtype' => 'checkbox',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'sid',
                'viewmingcheng' => '所属店铺',
                'inputtype' => 'select',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'introduction',
                'viewmingcheng' => '擅长与简介',
                'inputtype' => 'textarea',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 0
            ],
            [
                'fieldsmingcheng' => 'total_income',
                'viewmingcheng' => '总收入',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'income',
                'viewmingcheng' => '收入',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'points',
                'viewmingcheng' => '积分',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'create_time',
                'viewmingcheng' => '加入时间',
                'inputtype' => 'text',
                'is_input' => 0,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'email',
                'viewmingcheng' => '邮箱',
                'inputtype' => 'text',
                'is_import' => 1,
                'is_input' => 1
            ],
            [
                'fieldsmingcheng' => 'sort',
                'viewmingcheng' => '排序',
                'inputtype' => 'text',
                'is_import' => 1,
                'is_input' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'status',
                'viewmingcheng' => '是否审核',
                'inputtype' => 'switch',
                'is_input' => 1,
                'is_import' => 1
            ]

        ];

        $data['operatingcity'] = [
            [
                'fieldsmingcheng' => 'username',
                'viewmingcheng' => '帐号',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'password',
                'viewmingcheng' => '密码',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 0,
            ],
            [
                'fieldsmingcheng' => 'title',
                'viewmingcheng' => '名称',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'level',
                'viewmingcheng' => '等级',
                'inputtype' => 'select',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'areatype',
                'viewmingcheng' => '类型',
                'inputtype' => 'radio',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'region_name',
                'viewmingcheng' => '位置',
                'inputtype' => 'lbs',
                'is_sys' => 1,
                'is_front' => 1,
                'is_import' => 1,
                'is_input' => 0
            ],
            [
                'fieldsmingcheng' => 'province_id',
                'viewmingcheng' => '地区',
                'inputtype' => 'select',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'total_income',
                'viewmingcheng' => '总收入',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'income',
                'viewmingcheng' => '收入',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'cate_ids',
                'viewmingcheng' => '经营类目',
                'inputtype' => 'checkbox',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'create_time',
                'viewmingcheng' => '加入时间',
                'inputtype' => 'text',
                'is_input' => 0,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'end_time',
                'viewmingcheng' => '到期时间',
                'inputtype' => 'date',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'status',
                'viewmingcheng' => '是否审核',
                'inputtype' => 'switch',
                'is_input' => 1,
                'is_import' => 1
            ]

        ];

        $data['store'] = [
            [
                'fieldsmingcheng' => 'username',
                'viewmingcheng' => '帐号',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'password',
                'viewmingcheng' => '密码',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 0,
            ],
            [
                'fieldsmingcheng' => 'title',
                'viewmingcheng' => '店名',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'stid',
                'viewmingcheng' => '类型',
                'inputtype' => 'select',
                'is_front' => 0,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'store_logo',
                'viewmingcheng' => '店LOGO',
                'inputtype' => 'pics',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'license',
                'viewmingcheng' => '营业执照',
                'inputtype' => 'pics',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'tel',
                'viewmingcheng' => '电话',
                'inputtype' => 'text',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'region_name',
                'viewmingcheng' => '位置',
                'inputtype' => 'lbs',
                'is_sys' => 1,
                'is_front' => 1,
                'is_import' => 1,
                'is_input' => 0
            ],
            // [
            //     'fieldsmingcheng' => 'province_id',
            //     'viewmingcheng' => '地区',
            //     'inputtype' => 'select',
            //     'is_front' => 0,
            //     'is_input' => 1,
            //     'is_import' => 1,
            //     'is_listView' => 1
            // ],
            [
                'fieldsmingcheng' => 'total_income',
                'viewmingcheng' => '总收入',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'income',
                'viewmingcheng' => '收入',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1,
            ],
            [
                'fieldsmingcheng' => 'cate_ids',
                'viewmingcheng' => '可接的服务',
                'inputtype' => 'checkbox',
                'is_front' => 1,
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'create_time',
                'viewmingcheng' => '加入时间',
                'inputtype' => 'text',
                'is_input' => 0,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'end_time',
                'viewmingcheng' => '到期时间',
                'inputtype' => 'date',
                'is_input' => 1,
                'is_import' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'sort',
                'viewmingcheng' => '排序',
                'inputtype' => 'text',
                'is_import' => 1,
                'is_input' => 1,
                'is_listView' => 1
            ],
            [
                'fieldsmingcheng' => 'status',
                'viewmingcheng' => '是否审核',
                'inputtype' => 'switch',
                'is_input' => 1,
                'is_import' => 1
            ],
            [
                'fieldsmingcheng' => 'service_time',
                'viewmingcheng' => '服务时间',
                'inputtype' => 'text',
                'is_input' => 1,
                'is_import' => 1
            ],
            [
                'fieldsmingcheng' => 'introduction',
                'viewmingcheng' => '简介',
                'inputtype' => 'textarea',
                'is_input' => 1,
                'is_import' => 1
            ]

        ];

        $data =  self::setdata($data[$ptype], $ptype);
        self::createdata($data);
    }

    public static function setdata($data, $ptype)
    {
        $weid = weid();
        if (!empty($data)) {
            foreach ($data as &$vo) {
                $vo['weid'] = $weid;
                $vo['ptype'] = $ptype;
                if ($vo['is_sys'] === 0) {
                    $vo['is_sys'] = 0;
                } else {
                    $vo['is_sys'] = 1;
                }

                $vo['create_time'] = time();
                $vo['update_time'] = time();
                $vo['sort'] = 100;
                $vo['status'] = 1;
            }
        }
        return $data;
    }

    public static function createdata($data)
    {
        if (!empty($data)) {
            foreach ($data as $vo) {
                if (empty(self::where(['fieldsmingcheng' => $vo['fieldsmingcheng'], 'ptype' => $vo['ptype'], 'weid' => $vo['weid']])->find())) {
                    self::create($vo);
                }
            }
        }
        return $data;
    }
}
